/*
 
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineStore } from "pinia";

export interface ScreenState {
  screening: boolean;
  screenyulan: any[];
  accect: number;
}

export const useScreenStore = defineStore("screen", {
  state: (): ScreenState => ({
    screening: false, // 是否进入放映状态
    screenyulan: [
      {
        id: 0,
        timer: 10,
        display: "none",
      },
    ],
    //选中的场景索引号
    accect: 0,
  }),
  actions: {
    setScreening(screening: boolean) {
      this.screening = screening;
    },
    addyulan(obj: object) {
      this.screenyulan.push(obj);
    },
    setassect(index: number) {
      this.accect = index;
    },
    setsend(index: number, shu: number) {
      this.screenyulan[index].timer = shu;
    },
    setdisplay(index: number) {
      if (this.screenyulan[index].display == "none") {
        this.screenyulan[index].display = "flex";
        this.screenyulan.forEach((a, i) => {
          if (i != index) {
            this.screenyulan[i].display = "none";
          }
        });
      } else {
        this.screenyulan[index].display = "none";
      }
    },
    deletescreen(index: number) {
      var a = this.screenyulan.splice(index).slice(1);
      this.screenyulan.push.apply(
        this.screenyulan,
        a.map((e) => {
          --e.id;
          return e;
        })
      );
    },
  },
});
